package com.ad_hccm.dao;

import com.ad_hccm.domain.PatientUser;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * TODO 患者信息Dao
 */
@Mapper
public interface PatientUserDao {
    @Insert("insert into patient_user value(#{id},#{name},#{sex},#{address},#{phone},#{contactName},#{contactPhone},#{e_mail},#{doctorId},#{diagnosisDate})")
    public boolean save(PatientUser patientUser);

    @Update("update patient_user set name = #{name}, sex = #{sex}, address = #{address}, phone = #{phone}, contactName = #{contactName}, contactPhone = #{contactPhone}, e_mail = #{e_mail}, doctorId=#{doctorId}, diagnosisDate = #{diagnosisDate} where id=#{id}")
    public boolean update(PatientUser patientUser);

    @Select("select * from patient_user where id=#{id}")
    public PatientUser getById(String id);

    @Select("select * from patient_user where doctorId = #{id}")
    public List<PatientUser> getAll(String id);

    @Select("select * from patient_user where (name like #{search} or sex like #{search} or address like #{search} or phone like #{search} or contactName like #{search} or contactPhone like #{search}) and doctorId = #{id}")
    public List<PatientUser> search(String search,String id);

}
